import os

from fastapi import APIRouter
# 导入opencv库
import cv2
# 导入依赖包
import hyperlpr3 as lpr3

hyperlpr = APIRouter()


@hyperlpr.get("/user/{id}", summary="获取用户信息")
def get_user(id: int):
    print("id", id)
    return {"userId": id}



@hyperlpr.get('/hyperImg', summary='车牌识别')
async def hyperImg():
    catcher = lpr3.LicensePlateCatcher()
    image = cv2.imread("E:/2021/carImg/car.png")
    print(catcher(image))
    return {"message": image}



    # path = "E:\2021\carImg"
    #carFile = []
    #files = os.listdir(path)
    #for file in files:
    #    filePath = os.path.join(path, file)
    #    if os.path.isdir(filePath):
    #        carFile.append(filePath)
#
    ## 实例化识别对象
    #catcher = lpr3.LicensePlateCatcher()
    ## 读取图片
    #for img in carFile:
    #    image = cv2.imread(img)
    #    # 识别结果
    #    print(catcher(image))
    ## return {"message": code}
